package com.scsj.supermarket.presenter;

import com.scsj.supermarket.base.QueryCardBase;
import com.scsj.supermarket.bean.QueryCardBean;
import com.scsj.supermarket.model.QueryCardModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;

/**
 * 修改登录密码presenter
 */

public class QueryCardPresenter extends BasePresenter implements QueryCardBase.IPresenter {

    private QueryCardBase.IModel mModel;
    private QueryCardBase.IView mView;

    public QueryCardPresenter(QueryCardBase.IView view) {
        mView = view;
        mModel = new QueryCardModel(0);
    }


    @Override
    public void deliverData(String cardNum) {
        addSubscription(mModel.getData(cardNum, new ResponseCallback<QueryCardBean>() {
            @Override
            public void onSuccess(QueryCardBean result) {
                if (result.isValidated()) {
                    mView.showSuccessMsg("银行卡有效", result);
                } else {
                    mView.showErrorMsg(result.getMessages().get(0).getErrorCodes());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
            }
        }));
    }

}
